package dk.itu.samd.group2.tagapastry.messages;

import java.io.IOException;
import java.util.Vector;

import dk.itu.samd.group2.tagapastry.IndexRelative;
import dk.itu.samd.group2.tagapastry.Tag;
import dk.itu.samd.group2.tagapastry.TagapastryImpl;
import dk.itu.samd.group2.tagapastry.messages.forwardStrategies.ForwardStrategy;

import rice.p2p.commonapi.Endpoint;
import rice.p2p.commonapi.NodeHandle;
import rice.p2p.commonapi.rawserialization.InputBuffer;

/**
 * This interface is to be implemented by message classes that
 * are meant to be sent to other indexes to store or retreive info
 * @author naomi
 *
 */
public abstract class IndexMsg extends TagapastryMsg {

	protected ForwardStrategy forwardStrategy;
	
	public IndexMsg(Tag tag, NodeHandle sender) {
		super(tag, sender);
	}
	
	public IndexMsg(InputBuffer buf, Endpoint endpoint) throws IOException {
		super(buf, endpoint);
	}
	
	public abstract IndexMsg cloneForChild(IndexRelative child);
	
	public void forward(Vector<IndexRelative> children, TagapastryImpl tagaImpl) {
		forwardStrategy.forward(children, tagaImpl, this);
	}

	public abstract boolean indexCreator();
	
}
